<template>
  <div>
    <div class="list-btn">
      姓名:<Input v-model.trim="params.realname" placeholder="请输入姓名" style="width: 200px" clearable @keyup.enter.native="getList(url)" />
    </div>
    <div class="list-btn">
      手机号:<Input v-model.trim="params.phone" placeholder="请输入手机号" style="width: 200px" clearable @keyup.enter.native="getList(url)" />
    </div>
    <div class="list-btn">
      订单号:<Input v-model.trim="params.nid" placeholder="请输入订单号" style="width: 200px" clearable @keyup.enter.native="getList(url)" />
    </div>
    <div class="list-btn">
      申请时间:<DatePicker type="date" @on-change="startTime"  placeholder="选择开始时间" style="width: 200px"></DatePicker>
      ～<DatePicker type="date" @on-change="endTime"  placeholder="选择结束时间" style="width: 200px" ></DatePicker>
    </div>
    <div class="list-btn">
      <!-- <Select clearable style="width:200px" v-model="params.type" placeholder="状态">
        <Option v-for="item in typeList" :value="item.name" :key="item.id">{{ item.name }}</Option>
      </Select> -->
      <Button type="primary" @click="getList(url,'refresh')">搜索</Button>
    </div>
    <page-list :listTitle="listTitle" :list="list" :loading="loading" @selectItem="ids = $event;"></page-list>
    <page-button :current="params.pageCurrent"  :total="total" @changePageNum="params.pageCurrent = $event; getList(url)" @changePageSize="params.pageLimit = $event; getList(url)"></page-button>
    <Modal
        v-model="modal"
        width="380">
       <p style="font-size: 16px;padding: 35px 0 50px;text-align:center;">是否确定审核通过</p>
        <div style="margin-left: 200px;">
          <Button @click="cancel">拒绝</Button>
          <Button type="primary" @click="ok">通过</Button>
        </div>
    </Modal>
  </div>
</template>

<script>
  import listMixin from '../../mixin/list'
  import pageList from '../../template/listTemplate'
  import pageButton from '../../template/pageBtnTemplate'
  import confirmDialog from '../../template/confirmDialogTemplate'
  export default {
    mixins:[listMixin],
    components: {
      pageList,
      pageButton,
      confirmDialog
    },
    data () {
      return {
        nameList:[],
        modal:false,
        id:'',
        reviewId:'',
        reviewStatus:'',
        tag: {
          'title': '财务电核',
          'path': '/work/callReview/list'
        },
        listTitle: [
          {
            title: '订单号',
            width: 200,
            key: 'nid',
            align:'left',
          },
          {
            title: '用户姓名',
            key: 'realname',
            width:140,
            align:'center'
          },

          {
            title: '手机号',
            key: 'phone',
            width:140,
            align:'center',
            render: (h, params) => {
              let phone = params.row.phone;
              return h('div', phone?`${phone.substr(0,3)}****${phone.substr(7)}`:'—')
            }
          },
          {
            title: '借款金额(元)',
            key: 'money',
            width:140,
            align:'center',
            render:(h,params) => {
              return h('div',this.toYuan(params.row.money))
            }
          },
          {
            title: '借款费用(元)',
            key: 'loanCost',
            width:140,
            align:'center',
            render:(h,params) => {
              return h('div',this.toYuan(params.row.loanCost))
            }
          }, {
            title: '借款周期(天)',
            key: 'day',
            width:120,
            align:'center'
          }, {
            title: '银行名称',
            key: 'bankName',
            width:120,
            align:'center'
          },
          {
            title: '银行卡号',
            key: 'bankNum',
            width:220,
            align:'center'
          },
          {
            title: '申请时间',
            key: 'createTime',
            width:220,
            align:'center',
              render:(h,params) => {
              return h('div',this.getLocalTime(params.row.createTime))
            }
          },
          {
            title: '状态',
            key: 'reviewStatus',
            width:120,
            align:'center',
            render: (h,params) => {
              let d = this.getStatus(params.row.reviewStatus);
              let texts = '';
              texts = d.txt
              return h('div', {
                props: {},
                style:{
                  color:d.color
                }
              }, texts)
            }
          },
          {
            title: '操作',
            key: 'action',
            width: 120,
            align: 'center',
            render: (h, params) => {
              this.id = params.row.id;
              this.reviewStatus = params.row.reviewStatus;
              return h('div', [
                h('Button', {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  style: {

                  },
                  on: {
                    click: () => {
                      //this.modal = true;
                      this.$router.push({path:'/work/user/userEdit',query:{id:params.row.userId,type:'cw',iid:params.row.id}})
                    }
                  }
                }, '审核')
              ]);
            }
          }
        ],
        url: '/bkfinancialloan/audit/list',
        nameListUrl: '',
        params: {
         pageCurrent: 1,
         pageLimit: 10
        },

      }
    },
    mounted() {
      this.getUserId();
    },
    methods: {
       getUserId(){
        this.$post('/sys/user/info').then(res => {
          if(res.code == 0){
            this.reviewId = res.data.id
          }
        })
      },
      ok () {
        this.$post('/bkfinancialloan/audit',{
          id:this.id,
          reviewId:this.reviewId,
          reviewStatus:1,//审核通过
          repaymentStatus:1
        }).then (res => {
          if(res.code == 0){
             this.$Message.success('审核成功');
             this.modal = false;
             this.getList(this.url);
          }
        }).catch(e => console.log(e))

      },
      cancel () {
        this.$post('/bkfinancialloan/audit',{
          id:this.id,
          reviewId:this.reviewId,
          reviewStatus:2,//审核拒绝
          repaymentStatus:1
        }).then (res => {
          if(res.code == 0){
             this.$Message.error('审核拒绝');
             this.modal = false;
             this.getList(this.url);
          }
        }).catch(e => console.log(e))
      }
    },
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
  .list-btn{
    margin-bottom: 20px;
  }
 .vertical-center-modal{
        display: flex;
        align-items: center;
        justify-content: center;

        .ivu-modal{
            top: 0;
        }
    }
 .list-btn{
   margin-bottom: 5px;
   margin-right: 5px;
   display: inline-block;
 }
  .refresh-btn{
    float: right;
  }
  /deep/ .ivu-modal-footer{
  display: none;
}

</style>
